#include "nxbot.h"

void nxbot_jingleInit(void);

//Configuration of song notes and times
static unsigned char discJingle[] = {DO2, SOL1, DO1};
static unsigned int discTimes[] = {200,200,400};

static unsigned char battJingle[] = {SI2, MI1,SILENCE};
static unsigned int battTimes[] = {200,200,10000};

static unsigned char connJingle[] = {DO1, SOL1, DO2};
static unsigned int connTimes[] = {200,200,400};
/*
@brief  init function for initialization of all hardware devices: <p><ul><li>UART</li><li>Motors</li><li>Sensors</li><li>Sound</li>
				
*/
void nxbot_init(void)
{

	//Configuration of UART for serial communication with 
	comm_init(UART_BAUD_SELECT_DOUBLE_SPEED(BAUD_RATE,F_CPU), UART_FORMAT_8D0P1S, COMM_PORT);	
	
	//init of motors, disable them
	motors_init(5);
	motors_setVel((signed char)0,MOTOR_RIGHT);
	motors_setVel((signed char)0,MOTOR_LEFT);

	//init of sensors: IR, battery, bumpers
	sensors_init();
	
	//init of sound
	sound_init();
	
	//define jingles for sound
	nxbot_jingleInit();

	
	//enable interrupts
	sei();
}

void nxbot_jingleInit()
{
	J_CONN.notes = connJingle;
	J_CONN.times_ms = connTimes;
	J_CONN.duration = 3;
	J_CONN.repeat = 0;
	
	J_DISCONN.notes = discJingle;
	J_DISCONN.times_ms = discTimes;
	J_DISCONN.duration = 3;
	J_DISCONN.repeat = 0;	
	
	J_BATT.notes = battJingle;
	J_BATT.times_ms = battTimes;
	J_BATT.duration = 3;
	J_BATT.repeat = 0;	
	
}
